package com.xbongbong.sys.model.impl;

import com.xbongbong.sys.domain.dao.ConnectorConfigDao;
import com.xbongbong.sys.domain.entity.ConnectorConfigEntity;
import com.xbongbong.sys.model.ConnectorConfigModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 * 连接器配置
 * 创建时间 2021/5/25 4:21 PM
 * 修改时间 2021/5/25 4:21 PM
 * @author chy
 */
@Service("connectorConfigModel")
public class ConnectorConfigModelImpl implements ConnectorConfigModel {

    @Resource
    private ConnectorConfigDao connectorConfigDao;

    @Override
    public Integer insert(ConnectorConfigEntity entity) {
        return connectorConfigDao.insert(entity);
    }

    @Override
    public Integer update(ConnectorConfigEntity entity) {
        return connectorConfigDao.update(entity);
    }

    @Override
    public Integer save(ConnectorConfigEntity entity) {
        if(entity.getId() == null || Objects.equals(0, entity.getId())) {
            return insert(entity);
        }
        return update(entity);
    }

    @Override
    public List<ConnectorConfigEntity> getByCorpId(String corpid) {
        return connectorConfigDao.getByCorpid(corpid);
    }

    @Override
    public ConnectorConfigEntity getByModelId(String corpid, String modelId) {
        return connectorConfigDao.getByModelId(corpid, modelId);
    }

    @Override
    public List<String> findCorps() {
        return connectorConfigDao.findCorps();
    }

}
